package com.smartalarmclock.Logic;

import com.smartalarmclock.UI.Messages;
import com.smartalarmclock.UI.ScheduleActivityForProfile;
import com.smartalarmclock.UI.Games.MainGamesActivity;

import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.util.Log;
import android.widget.Toast;

public class AlarmClockBroadcastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.v("Alarm", "Alarm ringing!!!");
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
        wl.acquire();

        // Put here YOUR code.
		 //Open Schedule Activity window
		Intent gamesActivity = new Intent(context, MainGamesActivity.class);
		gamesActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(gamesActivity);

        wl.release();	
        
        KeyguardManager keyguardManager = (KeyguardManager) context.getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); 
        KeyguardLock keyguardLock =  keyguardManager.newKeyguardLock(getClass().getName());
        keyguardLock.disableKeyguard();
	}

}
